package javax.mail.event;

import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Transport;

public class TransportEvent extends MailEvent {
    protected transient Address[] invalid;
    protected transient Message msg;
    protected int type;
    protected transient Address[] validSent;
    protected transient Address[] validUnsent;

    public TransportEvent(Transport transport, int type, Address[] validSent, Address[] validUnsent, Address[] invalid, Message msg) {
        super(transport);
        this.type = type;
        this.validSent = validSent;
        this.validUnsent = validUnsent;
        this.invalid = invalid;
        this.msg = msg;
    }

    public void dispatch(Object listener) {
        if (this.type == 1) {
            ((TransportListener) listener).messageDelivered(this);
        } else if (this.type == 2) {
            ((TransportListener) listener).messageNotDelivered(this);
        } else {
            ((TransportListener) listener).messagePartiallyDelivered(this);
        }
    }
}
